//
//  GAKKIBaseCollectionViewController.h
//  GANGAIKit
//
//  Created by fh on 2019/11/7.
//  Copyright © 2019 cashchina. All rights reserved.
//

#import "GAKKIBaseViewController.h"
#import "GAKKIFeatureCollectionView.h"
#import "GAKKIBaseCollectionViewCell.h"
#import "GAKKIBaseCollectionReusableView.h"

NS_ASSUME_NONNULL_BEGIN

/// 瀑布流控制器基类
@interface GAKKIBaseCollectionViewController : GAKKIBaseViewController <UICollectionViewDataSource,UICollectionViewDelegate,GAKKIFeatureCollectionViewDelegate>

/// 集合视图控件,为了方便访问,提供该属性
@property (nonatomic, readonly, strong) UICollectionView *collectionView;

/// 是否数据是多段:默认NO
@property (nonatomic, readwrite, assign) BOOL shouldMultiSections;
/// 数据源
@property (nonatomic, readwrite, strong) NSMutableArray *dataSource;

/// 重写创建对象
+ (instancetype)new;

/// 重写初始化
- (instancetype)init; // NS_UNAVAILABLE

/// 用传递参数初始化
/// @param params 传递参数
- (instancetype)initWithParams:(NSDictionary * __nullable)params;

/// 用传递参数初始化并自定义属性设置
/// @param params 传递参数
/// @param settingBlock 自定义配置回调
- (instancetype)initWithParams:(NSDictionary * __nullable)params settingBlock:(void(^ __nullable)(GAKKIBaseViewController *vc))settingBlock;


/// 常用初始化方法:使用该方法进行初始化,该方法默认自己是事件的处理，如果是自定义layout需要在子类里遵循对应的协议
/// @param params 传递给页面的参数
/// @param collectionViewSettingBlock 集合视图UI布局配置回调
- (instancetype)initWithDefaultLayoutParams:(NSDictionary * __nullable)params customConfigurationSettingBlock:(void(^ __nullable)(GAKKIFeatureCollectionViewConfiguration * settingConfiguration))collectionViewSettingBlock;

/// 初始化方法
/// @param params 传递给页面的参数
/// @param collectionViewSettingBlock 集合视图UI布局配置回调
/// @param settingBlock 自身的配置回调
- (instancetype)initWithDefaultLayoutParams:(NSDictionary * __nullable)params customConfigurationSettingBlock:(void(^ __nullable)(GAKKIFeatureCollectionViewConfiguration * settingConfiguration))collectionViewSettingBlock settingBlock:(void(^ __nullable)(GAKKIBaseViewController *vc))settingBlock;

/// 底层初始化方法
/// @param params 传递给页面的参数
/// @param delegate 集合视图的代理:封装UICollectionViewDelegate的代理事件,默认为self,所以一般都是设置为nil
/// @param collectionViewSettingBlock 集合视图UI布局配置回调
/// @param collectionViewDelegate 集合视图代理,默认为self,所以一般都是设置为nil
/// @param settingBlock 自身的配置回调
- (instancetype)initWithDefaultLayoutParams:(NSDictionary * __nullable)params featureCollectionViewDelegate:(id<GAKKIFeatureCollectionViewDelegate> __nullable)delegate customConfigurationSettingBlock:(void(^ __nullable)(GAKKIFeatureCollectionViewConfiguration * settingConfiguration))collectionViewSettingBlock collectionViewDelegate:(id<UICollectionViewDelegate> __nullable)collectionViewDelegate settingBlock:(void(^ __nullable)(GAKKIBaseViewController *vc))settingBlock;;


/// 配置子视图:默认添加tableView并设置frame(已适配iPhoneX和iOS11),子类可以重写,重写必须自己添加tableView到父视图并设置frame : 重写父类方法
- (void)setupView;

/// 刷新数据
- (void)reloadData;


/// 注册cell:这个方法需要在
/// @param cellClass cell
/// @param identifier 重用符标示
- (void)registerClass:(Class)cellClass forCellWithReuseIdentifier:(NSString * __nullable)identifier;

@end

NS_ASSUME_NONNULL_END

// 刷新功能
#import "GAKKIBaseCollectionViewController+Refresh.h"
// 空数据功能
#import "GAKKIBaseCollectionViewController+EmptyData.h"
